*********************************************************************************************
use partisanidentity_polarization_finaldata_20200205.dta, clear

**Experimental Design-Treatment Assignments 
tab satreatment if purecontrol!=1 & wave==1
tab purecontrol if wave==1
tab satreatment if purecontrol!=1 & wave==2
tab purecontrol if wave==2



*********************************************************************************************
****** MANIP CHECKS (ONLY ASKED IN WAVE 2) -- comparing across controls
ttest mcindex if purecontrol!=1, by(satreatment)
ttest mcindex, by(satreatvspurecontrol)
ttest mcindex, by(selfandpurevsranking)

*********************************************************************************************


*********************************************************************************************
****** SUBJECT TREAT ASSIGN ACROSS WAVES
sort contactid wave

gen treatw1=0
by contactid: replace treatw1=1 if selfandpurevsranking==1 & wave==1 & panel==1
replace treatw1=treatw1[_n-1] if wave==2 & panel==1


gen treatw2=0
by contactid: replace treatw2=1 if selfandpurevsranking==1 & wave==2 & panel==1
replace treatw2=treatw2[_n+1] if wave==1 & panel==1

tab treatw1 treatw2 if panel==1


*********************************************************************************************



*********************************************************************************************

*** WAVE TREATMENT RESULTS (using true panel)
*********************  ALL  ********************* 
ttest colselfindex if  panel==1, by(wave)
ttest ideology1 if  panel==1, by(wave)
ttest inoutpartytherm if  panel==1, by(wave)
ttest inoutpartytraitsindex if  panel==1, by(wave)

*********************  DEMS  ********************* 
ttest colselfindex if democrat==1 & panel==1, by(wave)
ttest ideology1 if democrat==1 & panel==1, by(wave)
ttest inoutpartytherm if democrat==1 & panel==1, by(wave)
ttest inoutpartytraitsindex if democrat==1 & panel==1, by(wave)


*********************  REPS  ********************* 
ttest colselfindex if republican==1 & panel==1, by(wave)
ttest ideology1 if republican==1 & panel==1, by(wave)
ttest inoutpartytherm if republican==1 & panel==1, by(wave)
ttest inoutpartytraitsindex if republican==1 & panel==1, by(wave)



*** SA TREATMENT RESULTS (using all data--both panel and non-panel subjects)
*********************  ALL  ********************* 
ttest colselfindex, by(selfandpurevsranking)
ttest ideology1, by(selfandpurevsranking)
ttest inoutpartytherm, by(selfandpurevsranking)
ttest inoutpartytraitsindex, by(selfandpurevsranking)

*********************  DEMS  ********************* 
ttest colselfindex if democrat==1, by(selfandpurevsranking)
ttest ideology1 if democrat==1, by(selfandpurevsranking)
ttest inoutpartytherm if democrat==1, by(selfandpurevsranking)
ttest inoutpartytraitsindex if democrat==1, by(selfandpurevsranking)

*********************  REPS  ********************* 
ttest colselfindex if republican==1, by(selfandpurevsranking)
ttest ideology1 if republican==1, by(selfandpurevsranking)
ttest inoutpartytherm if republican==1, by(selfandpurevsranking)
ttest inoutpartytraitsindex if republican==1, by(selfandpurevsranking)





**** INTERACTION SA TREAT X WAVE RESULTS -- see separate do file for "figures"





********************************************************************************
********************************************************************************
********************************************************************************

* ####################### APPENDIX ####################### * 

********************************************************************************
********************************************************************************
********************************************************************************


****** DESCRIPTIVE STATS TABLE (BY PARTY AND WAVE)


sum colselfindex if republican==1 & wave==1
sum colselfindex if democrat==1 & wave==1
sum colselfindex if republican==1 & wave==2
sum colselfindex if democrat==1 & wave==2

sum white if republican==1 & wave==1
sum white if democrat==1 & wave==1
sum white if republican==1 & wave==2
sum white if democrat==1 & wave==2

sum income if republican==1 & wave==1
sum income if democrat==1 & wave==1
sum income if republican==1 & wave==2
sum income if democrat==1 & wave==2

sum employed if republican==1 & wave==1
sum employed if democrat==1 & wave==1
sum employed if republican==1 & wave==2
sum employed if democrat==1 & wave==2

sum age if republican==1 & wave==1
sum age if democrat==1 & wave==1
sum age if republican==1 & wave==2
sum age if democrat==1 & wave==2

sum bachelors if republican==1 & wave==1
sum bachelors if democrat==1 & wave==1
sum bachelors if republican==1 & wave==2
sum bachelors if democrat==1 & wave==2

sum ideology1 if republican==1 & wave==1
sum ideology1 if democrat==1 & wave==1
sum ideology1 if republican==1 & wave==2
sum ideology1 if democrat==1 & wave==2

*********************************************************************************************
****** SUBJECT TREAT ASSIGN ACROSS WAVES -- Original Treatment assignment (not combining treat and pure control)
clear
use panel_onlypartisans

sort contactid wave

gen originaltreatw1=0
by contactid: replace originaltreatw1=1 if satreatment==1 & wave==1 
replace originaltreatw1=originaltreatw1[_n-1] if wave==2

gen originaltreatw2=0
by contactid: replace originaltreatw2=1 if satreatment==1 & wave==2
replace originaltreatw2=originaltreatw2[_n+1] if wave==1

tab originaltreatw1 originaltreatw2


*********************************************************************************************



*********************************************************************************************
*Replication of Paper Results Dropping Pure Control Subjects
*********************************************************************************************

*** WAVE TREATMENT RESULTS (using true panel)
*********************  ALL  ********************* 
use partisanidentity_polarization_finaldata_20200205.dta, clear

ttest colselfindex if  panel==1 & purecontrol!=1, by(wave)
ttest ideology1 if  panel==1 & purecontrol!=1, by(wave)
ttest inoutpartytherm if   panel==1 & purecontrol!=1, by(wave)
ttest inoutpartytraitsindex if panel==1 & purecontrol!=1, by(wave)

*********************  DEMS  ********************* 
ttest colselfindex if democrat==1 & panel==1 & purecontrol!=1, by(wave)
ttest ideology1 if democrat==1 & panel==1 & purecontrol!=1, by(wave)
ttest inoutpartytherm if democrat==1 & panel==1 & purecontrol!=1, by(wave)
ttest inoutpartytraitsindex if democrat==1 & panel==1 & purecontrol!=1, by(wave)


*********************  REPS  ********************* 
ttest colselfindex if republican==1 & panel==1 & purecontrol!=1, by(wave)
ttest ideology1 if republican==1 & panel==1 & purecontrol!=1, by(wave)
ttest inoutpartytherm if republican==1 & panel==1 & purecontrol!=1, by(wave)
ttest inoutpartytraitsindex if republican==1 & panel==1 & purecontrol!=1, by(wave)



*** SA TREATMENT RESULTS (dropping pure control)
*********************  All  ********************* 
ttest colselfindex if  purecontrol!=1, by(selfandpurevsranking)
ttest ideology1 if  purecontrol!=1, by(selfandpurevsranking)
ttest inoutpartytherm if  purecontrol!=1, by(selfandpurevsranking)
ttest inoutpartytraitsindex if purecontrol!=1, by(selfandpurevsranking)

*********************  DEMS  ********************* 
ttest colselfindex if democrat==1 & purecontrol!=1, by(selfandpurevsranking)
ttest ideology1 if democrat==1 & purecontrol!=1, by(selfandpurevsranking)
ttest inoutpartytherm if democrat==1 & purecontrol!=1, by(selfandpurevsranking)
ttest inoutpartytraitsindex if democrat==1 & purecontrol!=1, by(selfandpurevsranking)

*********************  REPS  ********************* 
ttest colselfindex if republican==1 & purecontrol!=1, by(selfandpurevsranking)
ttest ideology1 if republican==1 & purecontrol!=1, by(selfandpurevsranking)
ttest inoutpartytherm if republican==1 & purecontrol!=1, by(selfandpurevsranking)
ttest inoutpartytraitsindex if republican==1 & purecontrol!=1, by(selfandpurevsranking)


*********************************************************************************************
*Individual Traits (not the index)
*********************************************************************************************
gen inoutparty_compromise=.
replace inoutparty_compromise=demsupporters_compromise - repsupporters_compromise if democrat==1
replace inoutparty_compromise=repsupporters_compromise - demsupporters_compromise if republican==1

gen inoutparty_patriotic=.
replace inoutparty_patriotic=demsupporters_patriotic - repsupporters_patriotic if democrat==1
replace inoutparty_patriotic=repsupporters_patriotic - demsupporters_patriotic if republican==1

gen inoutparty_selfish=.
replace inoutparty_selfish=demsupporters_selfish - repsupporters_selfish if democrat==1
replace inoutparty_selfish=repsupporters_selfish - demsupporters_selfish if republican==1

gen inoutparty_narrowmind=.
replace inoutparty_narrowmind=demsupporters_narrowmind - repsupporters_narrowmind if democrat==1
replace inoutparty_narrowmind=repsupporters_narrowmind - demsupporters_narrowmind if republican==1



*WAVE EFFECTS
*********************  ALL  ********************* 
ttest inoutparty_compromise if panel==1, by(wave)
ttest inoutparty_patriotic if panel==1, by(wave)
ttest inoutparty_narrowmind if panel==1, by(wave)
ttest inoutparty_selfish if panel==1, by(wave)

*********************  DEMS  ********************* 
ttest inoutparty_compromise if panel==1 & democrat==1, by(wave)
ttest inoutparty_patriotic if panel==1 & democrat==1, by(wave)
ttest inoutparty_narrowmind if panel==1 & democrat==1, by(wave)
ttest inoutparty_selfish if panel==1 & democrat==1, by(wave)

*********************  REPS  ********************* 
ttest inoutparty_compromise if panel==1 & republican==1, by(wave)
ttest inoutparty_patriotic if panel==1 & republican==1, by(wave)
ttest inoutparty_narrowmind if panel==1 & republican==1, by(wave)
ttest inoutparty_selfish if panel==1 & republican==1, by(wave)


*********************************************************************************************
*OUT PARTY TRAITS ONLY
*********************************************************************************************
gen outparty_compromise=.
replace outparty_compromise=repsupporters_compromise if democrat==1
replace outparty_compromise=demsupporters_compromise if republican==1

gen outparty_patriotic=.
replace outparty_patriotic=repsupporters_patriotic if democrat==1
replace outparty_patriotic= demsupporters_patriotic if republican==1

gen outparty_selfish=.
replace outparty_selfish=repsupporters_selfish if democrat==1
replace outparty_selfish=demsupporters_selfish if republican==1

gen outparty_narrowmind=.
replace outparty_narrowmind= repsupporters_narrowmind if democrat==1
replace outparty_narrowmind=demsupporters_narrowmind if republican==1



*WAVE EFFECTS
*********************  ALL  ********************* 
ttest outparty_compromise if panel==1, by(wave)
ttest outparty_patriotic if panel==1, by(wave)
ttest outparty_narrowmind if panel==1, by(wave)
ttest outparty_selfish if panel==1, by(wave)

*********************  DEMS  ********************* 
ttest outparty_compromise if panel==1 & democrat==1, by(wave)
ttest outparty_patriotic if panel==1 & democrat==1, by(wave)
ttest outparty_narrowmind if panel==1 & democrat==1, by(wave)
ttest outparty_selfish if panel==1 & democrat==1, by(wave)

*********************  REPS  ********************* 
ttest outparty_compromise if panel==1 & republican==1, by(wave)
ttest outparty_patriotic if panel==1 & republican==1, by(wave)
ttest outparty_narrowmind if panel==1 & republican==1, by(wave)
ttest outparty_selfish if panel==1 & republican==1, by(wave)


*********************************************************************************************
*SA TREAT EFFECT, CONTROLLING FOR IDEOLOGY IN REGRESSION
*********************************************************************************************
*********************  ALL  ********************* 

reg colselfindex selfandpurevsranking ideology1 
outreg2 using saeffects_controlideology.tex, replace dec(2) pdec(2)
reg inoutpartytherm selfandpurevsranking ideology1 
outreg2 using saeffects_controlideology.tex, append dec(2) pdec(2)
reg inoutpartytraitsindex selfandpurevsranking ideology1 
outreg2 using saeffects_controlideology.tex, append dec(2) pdec(2)

*********************  DEMS  ********************* 

reg colselfindex selfandpurevsranking ideology1 if democrat==1
outreg2 using saeffects_controlideology.tex, append dec(2) pdec(2)
reg inoutpartytherm selfandpurevsranking ideology1 if democrat==1
outreg2 using saeffects_controlideology.tex, append dec(2) pdec(2)
reg inoutpartytraitsindex selfandpurevsranking ideology1 if democrat==1
outreg2 using saeffects_controlideology.tex, append dec(2) pdec(2)

*********************  REPS  ********************* 

reg colselfindex selfandpurevsranking ideology1 if republican==1
outreg2 using saeffects_controlideology.tex, append dec(2) pdec(2)
reg inoutpartytherm selfandpurevsranking ideology1 if republican==1
outreg2 using saeffects_controlideology.tex, append dec(2) pdec(2)
reg inoutpartytraitsindex selfandpurevsranking ideology1 if republican==1
outreg2 using saeffects_controlideology.tex, append dec(2) pdec(2)




*********************************************************************************************
*INTERACTION EFFECT FIGURES-USING TRUE PANEL SUBJECTS ONLY
*********************************************************************************************
**** SEE SEPARATE DO FILE FOR FIGURES



*********************************************************************************************
*INTERACTION EFFECT FIGURES-Drop W1 Subjects Who Received Treatment for Wave 2 (no testing effects)
*********************************************************************************************
**** SEE SEPARATE DO FILE FOR FIGURES




*********************************************************************************************
*2SLS
*********************************************************************************************

* ##### WAVE EFFECTS
*********************  ALL  ********************* 
ivreg inoutpartytherm (colselfindex=wave) if  panel==1
outreg2 using 2slsresults_wave.tex, replace dec(2) pdec(2)
ivreg inoutpartytraitsindex (colselfindex=wave) if panel==1
outreg2 using 2slsresults_wave.tex, append dec(2) pdec(2)

*********************  DEMS  ********************* 
ivreg inoutpartytherm (colselfindex=wave) if democrat==1 & panel==1
outreg2 using 2slsresults_wave.tex, append dec(2) pdec(2)
ivreg inoutpartytraitsindex (colselfindex=wave) if democrat==1 & panel==1
outreg2 using 2slsresults_wave.tex, append dec(2) pdec(2)

*********************  REPS  ********************* 
ivreg inoutpartytherm (colselfindex=wave) if republican==1 & panel==1
outreg2 using 2slsresults_wave.tex, append dec(2) pdec(2)
ivreg inoutpartytraitsindex (colselfindex=wave) if republican==1 & panel==1
outreg2 using 2slsresults_wave.tex, append dec(2) pdec(2)



* ##### SELF AFFIRMATION
*********************  ALL  ********************* 
ivreg inoutpartytherm (colselfindex=selfandpure) 
outreg2 using 2slsresults_satreat.tex, replace dec(2) pdec(2)
ivreg inoutpartytraitsindex (colselfindex=selfandpure) 
outreg2 using 2slsresults_satreat.tex, append dec(2) pdec(2)

*********************  DEMS  ********************* 
ivreg inoutpartytherm (colselfindex=selfandpure) if democrat==1
outreg2 using 2slsresults_satreat.tex, append dec(2) pdec(2)
ivreg inoutpartytraitsindex (colselfindex=selfandpure) if democrat==1
outreg2 using 2slsresults_satreat.tex, append dec(2) pdec(2)

*********************  REPS  ********************* 
ivreg inoutpartytherm (colselfindex=selfandpure) if republican==1
outreg2 using 2slsresults_satreat.tex, append dec(2) pdec(2)
ivreg inoutpartytraitsindex (colselfindex=selfandpure) if republican==1
outreg2 using 2slsresults_satreat.tex, append dec(2) pdec(2)



*********************************************************************************************
****** SA Treatment in True Panel is Transient (so T in W1 no effect in W2)

clear
use panel_onlypartisans

sort contactid wave

gen treatw1=0
by contactid: replace treatw1=1 if selfandpurevsranking==1 & wave==1 
replace treatw1=treatw1[_n-1] if wave==2

gen treatw2=0
by contactid: replace treatw2=1 if selfandpurevsranking==1 & wave==2
replace treatw2=treatw2[_n+1] if wave==1

tab treatw1 treatw2


*** SA TREATMENT RESULTS (using true panel data)
*********************  ALL  ********************* 

ttest colselfindex if  wave==2, by(treatw1)
ttest ideology1 if  wave==2, by(treatw1)
ttest inoutpartytherm if  wave==2, by(treatw1)
ttest inoutpartytraitsindex if  wave==2, by(treatw1)

*********************  DEMS  ********************* 

ttest colselfindex if democrat==1 & wave==2, by(treatw1)
ttest ideology1 if democrat==1 & wave==2, by(treatw1)
ttest inoutpartytherm if democrat==1 & wave==2, by(treatw1)
ttest inoutpartytraitsindex if democrat==1 & wave==2, by(treatw1)

*********************  REPS  ********************* 
ttest colselfindex if republican==1 & wave==2, by(treatw1)
ttest ideology1 if republican==1 & wave==2, by(treatw1)
ttest inoutpartytherm if republican==1 & wave==2, by(treatw1)
ttest inoutpartytraitsindex if republican==1 & wave==2, by(treatw1)




*********************************************************************************************
